from os import getcwd,sep
from os.path import basename
import sys

from PyQt5.QtWidgets import QApplication
from ui.TextGUI import MyTextEdit
import logging


if __name__ == '__main__':
    logger = logging.getLogger(__name__)
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s %(levelname)s %(message)s\n' + "=" * 60,
        handlers=[
            logging.FileHandler('deBug.log', mode='a'),
            logging.StreamHandler()
        ]
    )
    # 关闭 chardet 日志的输出
    logging.getLogger('chardet.charsetprober').disabled = True
    logging.getLogger('chardet.universaldetector').disabled = True
    try:
        app = QApplication(sys.argv)
        app.setStyle("Fusion")
        exePath = getcwd() + sep + basename(sys.argv[0])
        myTextEdit = MyTextEdit(exePath, logging)
        myTextEdit.show()
        sys.exit(app.exec_())
    except Exception as e:
        logger.exception(e)

